<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
 <head>
  <title>cher2.f</title>
 <meta name="generator" content="emacs 21.3.1; htmlfontify 0.20">
<style type="text/css"><!-- 
body { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.default   { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.default a { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
span.string   { color: rgb(188, 143, 143);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.string a { color: rgb(188, 143, 143);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
span.comment   { color: rgb(178, 34, 34);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.comment a { color: rgb(178, 34, 34);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
 --></style>

 </head>
  <body>

<pre>
      SUBROUTINE <a name="CHER2.1"></a><a href="cher2.f.html#CHER2.1">CHER2</a>(UPLO,N,ALPHA,X,INCX,Y,INCY,A,LDA)
<span class="comment">*</span><span class="comment">     .. Scalar Arguments ..
</span>      COMPLEX ALPHA
      INTEGER INCX,INCY,LDA,N
      CHARACTER UPLO
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Array Arguments ..
</span>      COMPLEX A(LDA,*),X(*),Y(*)
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Purpose
</span><span class="comment">*</span><span class="comment">  =======
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  <a name="CHER2.14"></a><a href="cher2.f.html#CHER2.1">CHER2</a>  performs the hermitian rank 2 operation
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     A := alpha*x*conjg( y' ) + conjg( alpha )*y*conjg( x' ) + A,
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  where alpha is a scalar, x and y are n element vectors and A is an n
</span><span class="comment">*</span><span class="comment">  by n hermitian matrix.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Arguments
</span><span class="comment">*</span><span class="comment">  ==========
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  UPLO   - CHARACTER*1.
</span><span class="comment">*</span><span class="comment">           On entry, UPLO specifies whether the upper or lower
</span><span class="comment">*</span><span class="comment">           triangular part of the array A is to be referenced as
</span><span class="comment">*</span><span class="comment">           follows:
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              UPLO = 'U' or 'u'   Only the upper triangular part of A
</span><span class="comment">*</span><span class="comment">                                  is to be referenced.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              UPLO = 'L' or 'l'   Only the lower triangular part of A
</span><span class="comment">*</span><span class="comment">                                  is to be referenced.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           Unchanged on exit.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  N      - INTEGER.
</span><span class="comment">*</span><span class="comment">           On entry, N specifies the order of the matrix A.
</span><span class="comment">*</span><span class="comment">           N must be at least zero.
</span><span class="comment">*</span><span class="comment">           Unchanged on exit.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  ALPHA  - COMPLEX         .
</span><span class="comment">*</span><span class="comment">           On entry, ALPHA specifies the scalar alpha.
</span><span class="comment">*</span><span class="comment">           Unchanged on exit.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  X      - COMPLEX          array of dimension at least
</span><span class="comment">*</span><span class="comment">           ( 1 + ( n - 1 )*abs( INCX ) ).
</span><span class="comment">*</span><span class="comment">           Before entry, the incremented array X must contain the n
</span><span class="comment">*</span><span class="comment">           element vector x.
</span><span class="comment">*</span><span class="comment">           Unchanged on exit.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  INCX   - INTEGER.
</span><span class="comment">*</span><span class="comment">           On entry, INCX specifies the increment for the elements of
</span><span class="comment">*</span><span class="comment">           X. INCX must not be zero.
</span><span class="comment">*</span><span class="comment">           Unchanged on exit.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Y      - COMPLEX          array of dimension at least
</span><span class="comment">*</span><span class="comment">           ( 1 + ( n - 1 )*abs( INCY ) ).
</span><span class="comment">*</span><span class="comment">           Before entry, the incremented array Y must contain the n
</span><span class="comment">*</span><span class="comment">           element vector y.
</span><span class="comment">*</span><span class="comment">           Unchanged on exit.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  INCY   - INTEGER.
</span><span class="comment">*</span><span class="comment">           On entry, INCY specifies the increment for the elements of
</span><span class="comment">*</span><span class="comment">           Y. INCY must not be zero.
</span><span class="comment">*</span><span class="comment">           Unchanged on exit.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  A      - COMPLEX          array of DIMENSION ( LDA, n ).
</span><span class="comment">*</span><span class="comment">           Before entry with  UPLO = 'U' or 'u', the leading n by n
</span><span class="comment">*</span><span class="comment">           upper triangular part of the array A must contain the upper
</span><span class="comment">*</span><span class="comment">           triangular part of the hermitian matrix and the strictly
</span><span class="comment">*</span><span class="comment">           lower triangular part of A is not referenced. On exit, the
</span><span class="comment">*</span><span class="comment">           upper triangular part of the array A is overwritten by the
</span><span class="comment">*</span><span class="comment">           upper triangular part of the updated matrix.
</span><span class="comment">*</span><span class="comment">           Before entry with UPLO = 'L' or 'l', the leading n by n
</span><span class="comment">*</span><span class="comment">           lower triangular part of the array A must contain the lower
</span><span class="comment">*</span><span class="comment">           triangular part of the hermitian matrix and the strictly
</span><span class="comment">*</span><span class="comment">           upper triangular part of A is not referenced. On exit, the
</span><span class="comment">*</span><span class="comment">           lower triangular part of the array A is overwritten by the
</span><span class="comment">*</span><span class="comment">           lower triangular part of the updated matrix.
</span><span class="comment">*</span><span class="comment">           Note that the imaginary parts of the diagonal elements need
</span><span class="comment">*</span><span class="comment">           not be set, they are assumed to be zero, and on exit they
</span><span class="comment">*</span><span class="comment">           are set to zero.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  LDA    - INTEGER.
</span><span class="comment">*</span><span class="comment">           On entry, LDA specifies the first dimension of A as declared
</span><span class="comment">*</span><span class="comment">           in the calling (sub) program. LDA must be at least
</span><span class="comment">*</span><span class="comment">           max( 1, n ).
</span><span class="comment">*</span><span class="comment">           Unchanged on exit.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Level 2 Blas routine.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  -- Written on 22-October-1986.
</span><span class="comment">*</span><span class="comment">     Jack Dongarra, Argonne National Lab.
</span><span class="comment">*</span><span class="comment">     Jeremy Du Croz, Nag Central Office.
</span><span class="comment">*</span><span class="comment">     Sven Hammarling, Nag Central Office.
</span><span class="comment">*</span><span class="comment">     Richard Hanson, Sandia National Labs.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     .. Parameters ..
</span>      COMPLEX ZERO
      PARAMETER (ZERO= (0.0E+0,0.0E+0))
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Local Scalars ..
</span>      COMPLEX TEMP1,TEMP2
      INTEGER I,INFO,IX,IY,J,JX,JY,KX,KY
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. External Functions ..
</span>      LOGICAL <a name="LSAME.110"></a><a href="lsame.f.html#LSAME.1">LSAME</a>
      EXTERNAL <a name="LSAME.111"></a><a href="lsame.f.html#LSAME.1">LSAME</a>
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. External Subroutines ..
</span>      EXTERNAL <a name="XERBLA.114"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Intrinsic Functions ..
</span>      INTRINSIC CONJG,MAX,REAL
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Test the input parameters.
</span><span class="comment">*</span><span class="comment">
</span>      INFO = 0
      IF (.NOT.<a name="LSAME.123"></a><a href="lsame.f.html#LSAME.1">LSAME</a>(UPLO,<span class="string">'U'</span>) .AND. .NOT.<a name="LSAME.123"></a><a href="lsame.f.html#LSAME.1">LSAME</a>(UPLO,<span class="string">'L'</span>)) THEN
          INFO = 1
      ELSE IF (N.LT.0) THEN
          INFO = 2
      ELSE IF (INCX.EQ.0) THEN
          INFO = 5
      ELSE IF (INCY.EQ.0) THEN
          INFO = 7
      ELSE IF (LDA.LT.MAX(1,N)) THEN
          INFO = 9
      END IF
      IF (INFO.NE.0) THEN
          CALL <a name="XERBLA.135"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>(<span class="string">'<a name="CHER2.135"></a><a href="cher2.f.html#CHER2.1">CHER2</a> '</span>,INFO)
          RETURN
      END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Quick return if possible.
</span><span class="comment">*</span><span class="comment">
</span>      IF ((N.EQ.0) .OR. (ALPHA.EQ.ZERO)) RETURN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Set up the start points in X and Y if the increments are not both
</span><span class="comment">*</span><span class="comment">     unity.
</span><span class="comment">*</span><span class="comment">
</span>      IF ((INCX.NE.1) .OR. (INCY.NE.1)) THEN
          IF (INCX.GT.0) THEN
              KX = 1
          ELSE
              KX = 1 - (N-1)*INCX
          END IF
          IF (INCY.GT.0) THEN
              KY = 1
          ELSE
              KY = 1 - (N-1)*INCY
          END IF
          JX = KX
          JY = KY
      END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Start the operations. In this version the elements of A are
</span><span class="comment">*</span><span class="comment">     accessed sequentially with one pass through the triangular part
</span><span class="comment">*</span><span class="comment">     of A.
</span><span class="comment">*</span><span class="comment">
</span>      IF (<a name="LSAME.165"></a><a href="lsame.f.html#LSAME.1">LSAME</a>(UPLO,<span class="string">'U'</span>)) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Form  A  when A is stored in the upper triangle.
</span><span class="comment">*</span><span class="comment">
</span>          IF ((INCX.EQ.1) .AND. (INCY.EQ.1)) THEN
              DO 20 J = 1,N
                  IF ((X(J).NE.ZERO) .OR. (Y(J).NE.ZERO)) THEN
                      TEMP1 = ALPHA*CONJG(Y(J))
                      TEMP2 = CONJG(ALPHA*X(J))
                      DO 10 I = 1,J - 1
                          A(I,J) = A(I,J) + X(I)*TEMP1 + Y(I)*TEMP2
   10                 CONTINUE
                      A(J,J) = REAL(A(J,J)) +
     +                         REAL(X(J)*TEMP1+Y(J)*TEMP2)
                  ELSE
                      A(J,J) = REAL(A(J,J))
                  END IF
   20         CONTINUE
          ELSE
              DO 40 J = 1,N
                  IF ((X(JX).NE.ZERO) .OR. (Y(JY).NE.ZERO)) THEN
                      TEMP1 = ALPHA*CONJG(Y(JY))
                      TEMP2 = CONJG(ALPHA*X(JX))
                      IX = KX
                      IY = KY
                      DO 30 I = 1,J - 1
                          A(I,J) = A(I,J) + X(IX)*TEMP1 + Y(IY)*TEMP2
                          IX = IX + INCX
                          IY = IY + INCY
   30                 CONTINUE
                      A(J,J) = REAL(A(J,J)) +
     +                         REAL(X(JX)*TEMP1+Y(JY)*TEMP2)
                  ELSE
                      A(J,J) = REAL(A(J,J))
                  END IF
                  JX = JX + INCX
                  JY = JY + INCY
   40         CONTINUE
          END IF
      ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Form  A  when A is stored in the lower triangle.
</span><span class="comment">*</span><span class="comment">
</span>          IF ((INCX.EQ.1) .AND. (INCY.EQ.1)) THEN
              DO 60 J = 1,N
                  IF ((X(J).NE.ZERO) .OR. (Y(J).NE.ZERO)) THEN
                      TEMP1 = ALPHA*CONJG(Y(J))
                      TEMP2 = CONJG(ALPHA*X(J))
                      A(J,J) = REAL(A(J,J)) +
     +                         REAL(X(J)*TEMP1+Y(J)*TEMP2)
                      DO 50 I = J + 1,N
                          A(I,J) = A(I,J) + X(I)*TEMP1 + Y(I)*TEMP2
   50                 CONTINUE
                  ELSE
                      A(J,J) = REAL(A(J,J))
                  END IF
   60         CONTINUE
          ELSE
              DO 80 J = 1,N
                  IF ((X(JX).NE.ZERO) .OR. (Y(JY).NE.ZERO)) THEN
                      TEMP1 = ALPHA*CONJG(Y(JY))
                      TEMP2 = CONJG(ALPHA*X(JX))
                      A(J,J) = REAL(A(J,J)) +
     +                         REAL(X(JX)*TEMP1+Y(JY)*TEMP2)
                      IX = JX
                      IY = JY
                      DO 70 I = J + 1,N
                          IX = IX + INCX
                          IY = IY + INCY
                          A(I,J) = A(I,J) + X(IX)*TEMP1 + Y(IY)*TEMP2
   70                 CONTINUE
                  ELSE
                      A(J,J) = REAL(A(J,J))
                  END IF
                  JX = JX + INCX
                  JY = JY + INCY
   80         CONTINUE
          END IF
      END IF
<span class="comment">*</span><span class="comment">
</span>      RETURN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     End of <a name="CHER2.247"></a><a href="cher2.f.html#CHER2.1">CHER2</a> .
</span><span class="comment">*</span><span class="comment">
</span>      END

</pre>

 </body>
</html>
